/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.ReferenceSubProcess;
import bpmn.SubProcess;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Reference Sub Process</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.ReferenceSubProcessImpl#getSubProcessRef <em>Sub Process Ref</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ReferenceSubProcessImpl extends SubProcessImpl implements ReferenceSubProcess {
	/**
	 * The cached value of the '{@link #getSubProcessRef() <em>Sub Process Ref</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubProcessRef()
	 * @generated
	 * @ordered
	 */
	protected SubProcess subProcessRef;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ReferenceSubProcessImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.REFERENCE_SUB_PROCESS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SubProcess getSubProcessRef() {
		if (subProcessRef != null && subProcessRef.eIsProxy()) {
			InternalEObject oldSubProcessRef = (InternalEObject)subProcessRef;
			subProcessRef = (SubProcess)eResolveProxy(oldSubProcessRef);
			if (subProcessRef != oldSubProcessRef) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.REFERENCE_SUB_PROCESS__SUB_PROCESS_REF, oldSubProcessRef, subProcessRef));
			}
		}
		return subProcessRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SubProcess basicGetSubProcessRef() {
		return subProcessRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSubProcessRef(SubProcess newSubProcessRef) {
		SubProcess oldSubProcessRef = subProcessRef;
		subProcessRef = newSubProcessRef;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.REFERENCE_SUB_PROCESS__SUB_PROCESS_REF, oldSubProcessRef, subProcessRef));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.REFERENCE_SUB_PROCESS__SUB_PROCESS_REF:
				if (resolve) return getSubProcessRef();
				return basicGetSubProcessRef();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.REFERENCE_SUB_PROCESS__SUB_PROCESS_REF:
				setSubProcessRef((SubProcess)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.REFERENCE_SUB_PROCESS__SUB_PROCESS_REF:
				setSubProcessRef((SubProcess)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.REFERENCE_SUB_PROCESS__SUB_PROCESS_REF:
				return subProcessRef != null;
		}
		return super.eIsSet(featureID);
	}

} //ReferenceSubProcessImpl
